from math import sqrt
a=input().split()
b=""
for i in a:
    if len(b)!=3:
        print("Wrong input")
        break
    elif i =="zero":
        b+="0"
    elif i=="one" :
        b+="1"
    elif i=="two" :
        b+="2"
    elif i=="three" :
        b+="3"
    elif i== "four":
        b+="4"
    elif i=="five" :
        b+="5"
    elif i=="six":
        b+="6"
    elif i=="seven":
        b+="7"
    elif i=="eight" :
        b+="8"
    elif i=="nine":
        b+="9"
    else:
        print ("Wrong input")
        break
else:
    c=int(b)
    def is_prime(num):
        d = 2
        if num > 1:
            while (num % d) != 0:
                d = d + 1
        return (d == num)
    plus = c
    minus = c
    res = 0
    res1 = 0
    res2 = 0
    if not is_prime(c):
        while not is_prime(plus):
            plus = plus + 1
        while not is_prime(minus):
            if minus == 1:
                minus = -1
                break
            minus = minus - 1
        if (c - minus) > (plus - c):
            res = plus
            print(res)
        elif (c - minus) < (plus - c):
            res = minus
            print(res)
        else:
            res1 = minus
            res2 = plus
            print("{}, {}".format(res1, res2))